package com.ylfstu.try_;

import java.util.Scanner;

/**
 * @author:Joy_Yang
 * @date:2022/9/27
 * @version:1.0
 */
public class TryCatchExercise {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int i;
        while (true) {
            System.out.println("请输入一个整数：");
            String inputStr = scanner.next();
            try {
                i = Integer.parseInt(inputStr);
                break;
            } catch (NumberFormatException e) {
                System.out.println("抱歉！你输入的不是一个整数...");
            }
        }

        System.out.println("你输入的值是：" + i);
    }
}
